// 重构3 
#[derive(Debug)]
struct Rectangle {
    width: u32,
    height: u32,
}

fn main() {
    //重构1
    // let width1 =30;
    // let height1 = 50;
    // 重构2
    // let rect1 = (30, 50);
    // 重构3
    let rect1 = Rectangle{
        width: 30,
        height: 50,
    };

    println!("The area of the rectangle is {} square pixels.",
    // 重构1 
    // area(width1, height1)
    // 重构2
    // area(rect1)
    // 重构3
    area(&rect1)
    );

    println!("rect1 is {:?}", rect1);// 打印结构体
    println!("rect1 is {:#?}", rect1);
}
// 重构1
// fn area(width: u32, height: u32) -> u32 {
//     width * height
// }
// 重构2
// fn area(dimensions: (u32, u32)) -> u32 {
//     dimensions.0 * dimensions.1
// }
// 重构3
fn area(rectangle: &Rectangle) -> u32 {
    rectangle.width * rectangle.height
}